package dailearn.zuul.controllerAdvice;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author daify
 * @date 2019-07-08
 */
@ControllerAdvice
@Slf4j
public class ZuulRestControllerAdvice {

    /**
     * 全局异常处理，反正异常返回统一格式的map
     * @param ex
     * @return
     */
    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public String exceptionHandler(Exception ex){
        log.error("------------------------------------");
        log.error("发生了异常");
        log.error(ex.getMessage());
        return "error";
    }
}
